/********************************************************************
FileName    :   Bll_yw_pdbH.cs
CreateTime  :   2015-09-18 12:09
BaseClass   :   Bll_yw_pdbH
FileType    :   .cs
Author      :  minjie
Description :   Bll_yw_pdbHBLL层（简单三层）
*********************************************************************/

using System;
using System.Text;
using System.Collections.Generic;

using System.Data;
using OS.Common;
using OS.DAL;
namespace OS.BLL
{
	/// <summary>
	/// Bll_yw_pdbH的摘要说明。
	/// </summary>
public partial class   Bll_yw_pdbH 
  	{ 
     		      
  		private readonly Dal_yw_pdbH dal=new  Dal_yw_pdbH(); 
  		public  Bll_yw_pdbH() 
  		{} 
  		 
  		#region  Method 
  		/// <summary> 
  		/// 增加一条数据 
  		/// </summary> 
  		public bool  Add(yw_pdbH_Entity model) 
  		{ 
  			return dal.Add(model); 
  		}
        public bool Exists(string pddh, ref int djlsh)
        {
            return dal.Exists(pddh,ref djlsh);
        }
        public int GetNewLsh()
        {
            int newLsh = 0;
            string sql = " select djlsh  from dbo.STDjLsh  where djname='YW_PDB'";
            string sql2 = "update STDjLsh set djlsh=djlsh+1 where djname='YW_PDB'";
            object obj = dal.GetSingle(sql);
            int ss = dal.ExecuteSql(sql2);
            if (obj != null && obj.ToString() != "")
            {
                newLsh = int.Parse(obj.ToString());
            }
            return newLsh;
        }

        /// <summary> 
        /// 增加一条数据 
        /// </summary> 
        public  string  AddStr(yw_pdbH_Entity model) 
  		{ 
  			return dal.AddStr(model); 
  		}
        public string UpdateStr(yw_pdbH_Entity model)
        {
            return dal.UpdateStr(model);
        }
        /// <summary> 
        /// 更新一条数据 
        /// </summary> 
        public bool Update(yw_pdbH_Entity model) 
  		{ 
  			return dal.Update(model); 
  		} 
   
  		/// <summary> 
  		/// 删除一条数据 
  		/// </summary> 
  		public bool Delete(int  DjLsh) 
  		{ 
  			 
  			return dal.Delete(DjLsh); 
  		} 
  		/// <summary> 
  		/// 批量删除一批数据 
  		/// </summary> 
  		public bool DeleteList(string DjLshlist ) 
  		{ 
  			return dal.DeleteList(DjLshlist ); 
  		} 
  		/// <summary> 
  		/// 得到一个对象实体 
  		/// </summary> 
  		public yw_pdbH_Entity GetModel(int  DjLsh) 
  		{ 
  			 
  			return dal.GetModel(DjLsh); 
  		} 
   
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public DataSet GetList(string strWhere) 
  		{ 
  			return dal.GetList(strWhere); 
  		} 
  		/// <summary> 
  		/// 获得前几行数据 
  		/// </summary> 
  		public DataSet GetList(int Top,string strWhere,string filedOrder) 
  		{ 
  			return dal.GetList(Top,strWhere,filedOrder); 
  		} 
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public List<yw_pdbH_Entity> GetModelList(string strWhere) 
  		{ 
  			DataSet ds = dal.GetList(strWhere); 
  			return DataTableToList(ds.Tables[0]); 
  		} 
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public List<yw_pdbH_Entity> GetModelList(string strWhere, string orderby, int startIndex, int endIndex) 
  		{ 
  			DataSet ds = dal.GetListByPage(strWhere, orderby, startIndex, endIndex); 
  			return DataTableToList(ds.Tables[0]); 
  		} 
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public List<yw_pdbH_Entity> DataTableToList(DataTable dt) 
  		{ 
  			List<yw_pdbH_Entity> modelList = new List<yw_pdbH_Entity>(); 
  		  if (dt!=null ) 
  		  { 
  			int rowsCount = dt.Rows.Count; 
  			if (rowsCount > 0) 
  			{ 
  				yw_pdbH_Entity   model; 
  				for (int n = 0; n < rowsCount; n++) 
  				{ 
  					model = new yw_pdbH_Entity();					 
  				if(dt.Rows[n]["DjLsh"]!=null&&dt.Rows[n]["DjLsh"].ToString()!="") 
  				{ 
  					model.DjLsh=int.Parse(dt.Rows[n]["DjLsh"].ToString()); 
  				} 
  				if(dt.Rows[n]["DjBtZdh"]!=null&&dt.Rows[n]["DjBtZdh"].ToString()!="") 
  				{ 
  					model.DjBtZdh=int.Parse(dt.Rows[n]["DjBtZdh"].ToString()); 
  				} 
  				if(dt.Rows[n]["DjFtZdh"]!=null&&dt.Rows[n]["DjFtZdh"].ToString()!="") 
  				{ 
  					model.DjFtZdh=int.Parse(dt.Rows[n]["DjFtZdh"].ToString()); 
  				} 
  				if(dt.Rows[n]["DjStZdh"]!=null&&dt.Rows[n]["DjStZdh"].ToString()!="") 
  				{ 
  					model.DjStZdh=int.Parse(dt.Rows[n]["DjStZdh"].ToString()); 
  				} 
  				model.DjState= dt.Rows[n]["DjState"].ToString(); 
  				if(dt.Rows[n]["DjCount"]!=null&&dt.Rows[n]["DjCount"].ToString()!="") 
  				{ 
  					model.DjCount=int.Parse(dt.Rows[n]["DjCount"].ToString()); 
  				} 
  				if(dt.Rows[n]["pdrq"]!=null&&dt.Rows[n]["pdrq"].ToString()!="") 
  				{ 
  					model.pdrq=DateTime.Parse(dt.Rows[n]["pdrq"].ToString()); 
  				} 
  				if(dt.Rows[n]["pdsj"]!=null&&dt.Rows[n]["pdsj"].ToString()!="") 
  				{ 
  					model.pdsj=DateTime.Parse(dt.Rows[n]["pdsj"].ToString()); 
  				} 
  				model.djzt= dt.Rows[n]["djzt"].ToString(); 
  				model.pddh= dt.Rows[n]["pddh"].ToString(); 
  				model.bmmc= dt.Rows[n]["bmmc"].ToString(); 
  				model.bmh= dt.Rows[n]["bmh"].ToString(); 
  				model.ckbh= dt.Rows[n]["ckbh"].ToString(); 
  				model.ckmc= dt.Rows[n]["ckmc"].ToString(); 
  				model.pdlb= dt.Rows[n]["pdlb"].ToString(); 
  				model.gysmc= dt.Rows[n]["gysmc"].ToString(); 
  				model.pdfs= dt.Rows[n]["pdfs"].ToString(); 
  				if(dt.Rows[n]["pdslhj"]!=null&&dt.Rows[n]["pdslhj"].ToString()!="") 
  				{ 
  					model.pdslhj=decimal.Parse(dt.Rows[n]["pdslhj"].ToString()); 
  				} 
  				if(dt.Rows[n]["pdjehj"]!=null&&dt.Rows[n]["pdjehj"].ToString()!="") 
  				{ 
  					model.pdjehj=decimal.Parse(dt.Rows[n]["pdjehj"].ToString()); 
  				} 
  				if(dt.Rows[n]["pdjjjehe"]!=null&&dt.Rows[n]["pdjjjehe"].ToString()!="") 
  				{ 
  					model.pdjjjehe=decimal.Parse(dt.Rows[n]["pdjjjehe"].ToString()); 
  				} 
  				if(dt.Rows[n]["zmslhj"]!=null&&dt.Rows[n]["zmslhj"].ToString()!="") 
  				{ 
  					model.zmslhj=decimal.Parse(dt.Rows[n]["zmslhj"].ToString()); 
  				} 
  				if(dt.Rows[n]["zmjehj"]!=null&&dt.Rows[n]["zmjehj"].ToString()!="") 
  				{ 
  					model.zmjehj=decimal.Parse(dt.Rows[n]["zmjehj"].ToString()); 
  				} 
  				if(dt.Rows[n]["zmjjjehe"]!=null&&dt.Rows[n]["zmjjjehe"].ToString()!="") 
  				{ 
  					model.zmjjjehe=decimal.Parse(dt.Rows[n]["zmjjjehe"].ToString()); 
  				} 
  				if(dt.Rows[n]["ykslhj"]!=null&&dt.Rows[n]["ykslhj"].ToString()!="") 
  				{ 
  					model.ykslhj=decimal.Parse(dt.Rows[n]["ykslhj"].ToString()); 
  				} 
  				if(dt.Rows[n]["ykjehj"]!=null&&dt.Rows[n]["ykjehj"].ToString()!="") 
  				{ 
  					model.ykjehj=decimal.Parse(dt.Rows[n]["ykjehj"].ToString()); 
  				} 
  				if(dt.Rows[n]["ykjjjehe"]!=null&&dt.Rows[n]["ykjjjehe"].ToString()!="") 
  				{ 
  					model.ykjjjehe=decimal.Parse(dt.Rows[n]["ykjjjehe"].ToString()); 
  				} 
  				model.bz= dt.Rows[n]["bz"].ToString(); 
  				model.zdr= dt.Rows[n]["zdr"].ToString(); 
  				if(dt.Rows[n]["zdsj"]!=null&&dt.Rows[n]["zdsj"].ToString()!="") 
  				{ 
  					model.zdsj=DateTime.Parse(dt.Rows[n]["zdsj"].ToString()); 
  				} 
  				model.shr= dt.Rows[n]["shr"].ToString(); 
  				if(dt.Rows[n]["shsj"]!=null&&dt.Rows[n]["shsj"].ToString()!="") 
  				{ 
  					model.shsj=DateTime.Parse(dt.Rows[n]["shsj"].ToString()); 
  				} 
  				model.sjfs= dt.Rows[n]["sjfs"].ToString(); 
  				 
  					modelList.Add(model); 
  				} 
  			} 
  		} 
  			return modelList; 
  		} 
   
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public DataSet GetAllList() 
  		{ 
  			return GetList(""); 
  		} 
   
  		/// <summary> 
  		/// 获取记录总数 
  		/// </summary> 
  		public int GetRecordCount(string strWhere) 
  		{ 
  			return  dal.GetRecordCount(strWhere); 
  		}
        #endregion
        /// <summary> 
        /// 批量处理 
        /// </summary> 
        public int ExecuteSqlTran(List<string> ls, ref string error)
        {
            return dal.ExecuteSqlTran(ls, ref error);
        }

    }

}
